<?php

namespace App\Listeners\Scratch;

use App\Events\ScratchCreated;
use App\Morefun\Scratch\RedisSynchronizer as ScratchRedisSynchronizer;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class WriteScratchToRedis
{
    protected $synchronizer;

    /**
     * @param ScratchRedisSynchronizer $synchronizer
     * Create the event listener.
     */
    public function __construct(ScratchRedisSynchronizer $synchronizer)
    {
        $this->synchronizer = $synchronizer;
    }

    /**
     * Handle the event.
     *
     * @param  ShakingCreated  $event
     * @return void
     */
    public function handle(ScratchCreated $event)
    {
        $this->synchronizer->write($event->activity);
    }
}
